package cn.ichiva.dl4j.gnn.mnist.data;

import org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator;

import java.io.IOException;

public class MnistData {

    private static final String resources = MnistData.class.getClassLoader().getResource("MNIST").getFile();

    /**
     * 训练数据
     */
    public static final ThreadLocal<PathMnistDataSetIterator> localTrainData = ThreadLocal.withInitial(() -> {
        try {
            return new PathMnistDataSetIterator(resources,128, true, 0);
        } catch (IOException e) {
            throw new RuntimeException("mnist 文件读取失败");
        }
    });

    /**
     * 测试数据
     */
    public static final ThreadLocal<PathMnistDataSetIterator> localTestData = ThreadLocal.withInitial(() -> {
        try {
            return new PathMnistDataSetIterator(resources,128, false, 0);
        } catch (IOException e) {
            throw new RuntimeException("mnist 文件读取失败");
        }
    });

}
